﻿function ApplyFilter(dde, fieldname, dateFrom, dateTo, container) {
    var d1 = dateFrom.GetText();
    var d2 = dateTo.GetText();
    if (d1 == "" || d2 == "")
        return;
    var newValue = d1 + " 至 " + d2;
    var oldValue = dde.lastSuccessText;
    dde.SetText(newValue);
    if (newValue != oldValue)
        container.AutoFilterByColumn(fieldname, dde.GetText());
}

function RemoveFilter(dde, fieldname, container) {
    dde.SetText('');
    container.AutoFilterByColumn(fieldname, '');
}

function OnDropDown(s, dateFrom, dateTo) {
    var str = s.GetText();
    if (str == "") {
        dateFrom.SetDate(new Date(2011, 1, 1));
        dateTo.SetDate(new Date());
        return;
    }
    var d = str.split(" 至 ");
    dateFrom.SetText(d[0]);
    dateTo.SetText(d[1]);
}